<?php
include 'common.php';
include 'app/crypt.php';
$csvFile = 'user_decrypt.csv';
$csvFile2 = 'user_latest.csv';

$csvData2 = csv2arr($csvFile2);
$mappingArr = array();
$i = 1;
foreach ($csvData2 as $key => $row) {
    $i++;
    if ($row['ID'] != '') {
        $arr['ID'] = my_decrypt($row['ID'], 'shastastation');
        $arr['Pass'] = my_decrypt($row['Pass'], 'Mt.Shasta');
        $mappingArr[] = $arr;
    }
    
    //if ($i == 50) break;
}
//debugdie($mappingArr);
debugdie(array_to_csv($mappingArr, 1, ",", "\n", '"'));
ob_clean();
header('Content-Disposition: attachment; filename="template_csv_import.csv"');
header('Content-type: text/csv');
$outstream = fopen("php://temp", 'w');
fwrite($outstream, array_to_csv($mappingArr, 1, ",", "\n", '"'));
rewind($outstream);
//$csv = preg_replace('/\r\n|\n/', "\r\n", stream_get_contents($outstream));
fclose($outstream);